package com.itestor.iptv.utils;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

/**
 * @author Mr.li
 */
public class XMLConverter {
	/**
	 * xStream.
	 */
	private static final XStream xStream = new XStream(new DomDriver());

	/**
	 * 将对象转成xml.
	 * @param object 对象.
	 * @return String
	 */
	public static String toXML(Object object) {
		return xStream.toXML(object);
	}

	/**
	 * 将xml转成对象.
	 * @param xml xml
	 * @return Object
	 */
	public static Object fromXML(String xml) {
		return xStream.fromXML(xml);
	}

	@SuppressWarnings("unchecked")
	public static void addAlias(String name, Class type) {
		xStream.alias(name, type);
	}

}
